package IO流.二维条形码;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.WriterException;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.qrcode.QRCodeWriter;

import javax.imageio.ImageIO;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class 二维码 {
    public static void main(String[] args) throws WriterException, IOException {
        //生成Q'rcode
        var bm=new QRCodeWriter().encode("http://img0.baidu.com/it/u=1119515913,3748293383&fm=26&fmt=auto", BarcodeFormat.QR_CODE,200,200);
        var i= MatrixToImageWriter.toBufferedImage(bm);
        ImageIO.write(i,"png",new FileOutputStream("e:/dd.png"));
        Runtime.getRuntime().exec("cmd /k start E:/dd.png");
    }
}
